package com.yjz.common.base;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

/**
 * 作用 :
 * 作者 : yjz
 * 时间 : 2024/10/15 14:44
 */
public abstract class BaseFragment extends Fragment {

    protected View layoutView;

    @LayoutRes
    public abstract int getLayoutId();

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        layoutView = inflater.inflate(getLayoutId(), container, false);
        return layoutView;
    }

    // 检测 宿主 是否还存活
    public boolean isAlive() {
        return !isRemoving() && !isDetached() && getActivity() != null;
    }
}
